<?php

/**
 * Staff form base class.
 *
 * @method Staff getObject() Returns the current form's model object
 *
 * @package    erp-dnict
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BaseStaffForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'             => new sfWidgetFormInputHidden(),
      'reference'      => new sfWidgetFormInputText(),
      'name'           => new sfWidgetFormInputText(),
      'email'          => new sfWidgetFormInputText(),
      'birth_place'    => new sfWidgetFormInputText(),
      'birthday'       => new sfWidgetFormDate(),
      'address'        => new sfWidgetFormInputText(),
      'id_number'      => new sfWidgetFormInputText(),
      'id_date_issue'  => new sfWidgetFormDate(),
      'id_place_issue' => new sfWidgetFormInputText(),
      'contract_date'  => new sfWidgetFormDate(),
      'start_date'     => new sfWidgetFormDate(),
      'is_active'      => new sfWidgetFormInputCheckbox(),
      'profile_id'     => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Profile'), 'add_empty' => false)),
      'created_at'     => new sfWidgetFormDateTime(),
      'updated_at'     => new sfWidgetFormDateTime(),
    ));

    $this->setValidators(array(
      'id'             => new sfValidatorChoice(array('choices' => array($this->getObject()->get('id')), 'empty_value' => $this->getObject()->get('id'), 'required' => false)),
      'reference'      => new sfValidatorString(array('max_length' => 20)),
      'name'           => new sfValidatorString(array('max_length' => 100)),
      'email'          => new sfValidatorString(array('max_length' => 255)),
      'birth_place'    => new sfValidatorString(array('max_length' => 32)),
      'birthday'       => new sfValidatorDate(),
      'address'        => new sfValidatorPass(),
      'id_number'      => new sfValidatorString(array('max_length' => 20)),
      'id_date_issue'  => new sfValidatorDate(),
      'id_place_issue' => new sfValidatorString(array('max_length' => 32)),
      'contract_date'  => new sfValidatorDate(),
      'start_date'     => new sfValidatorDate(),
      'is_active'      => new sfValidatorBoolean(array('required' => false)),
      'profile_id'     => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Profile'))),
      'created_at'     => new sfValidatorDateTime(),
      'updated_at'     => new sfValidatorDateTime(),
    ));

    $this->validatorSchema->setPostValidator(
      new sfValidatorDoctrineUnique(array('model' => 'Staff', 'column' => array('reference')))
    );

    $this->widgetSchema->setNameFormat('staff[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Staff';
  }

}
